#pragma once

#include <d3d9.h>
#include <d3dx9.h>
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")

#include "DrawList.h"
#include "Definitions.h"

class Model;
class SpriteNode;
class TextNode;

class Render
{
private:
	int count;
	D3DPRESENT_PARAMETERS	d3dpp;
	LPDIRECT3D9             pD3D;
	LPDIRECT3DDEVICE9       pd3dDevice;
private:
	//Sprite
	//Matrices used to move, scale, and rotate the sprite object
	D3DXMATRIX spriteMat, spriteScale, spriteRotate, spriteTranslate;
	ID3DXSprite*		sprite;	//Sprite object (only one is needed)
	IDirect3DTexture9*	texture[NUM_SPRITES];

	//Font
	ID3DXFont* Font[NUM_FONTS];

	//shared
	D3DCOLOR	color;
private:
	int numTextures, maxTextures;
private:
	DrawList list;
	Model* model;
private:
	Render(){Init();}
	void Init();
	void renderSprite(SpriteNode*);
	void renderText(TextNode*);
public:
	//Calls from Controller
	void RenderFrame();
public:
	//Calls from everything else
	inline static Render* getInstance()	{static Render instance; return &instance;}
		//returns reference number
	int LoadTexture(char*);
	int LoadTexture(char*, int, int);
	void AddToDrawList(DrawNode*);
};